package keeto.com.vn.bms.network.task;

import java.io.IOException;

import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.network.request.UpdateAndroidScheduleRequest;
import keeto.com.vn.bms.network.response.UpdateAndroidScheduleResponse;
import keeto.com.vn.bms.utils.BMSListener;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

public class TaskUpdateAndroidSchedule extends AbstractTask{
	private String Code;
	private String Name;
	private String Price;
	private String Execute_date;
	private String AuthKey;
	private int Hospital_id;
	private String Address;
	private int Level;
	private int Case_id;
	private String AddInfos;
	private int SchedUserRole_id;
	private String TypeCost;
	private String ID;
	private String aRequire;
	private int User_id;
	
	
	
	public TaskUpdateAndroidSchedule(BMSListener listener, IBMSCore core,
			String code, String name, String price, String execute_date,
			String authKey, int hospital_id, String address, int level,
			int case_id, String addInfos, int schedUserRole_id,
			String typeCost, String iD, String Require, int User_id) {
		super(listener, core);
		Code = code;
		Name = name;
		Price = price;
		Execute_date = execute_date;
		AuthKey = authKey;
		Hospital_id = hospital_id;
		Address = address;
		Level = level;
		Case_id = case_id;
		AddInfos = addInfos;
		SchedUserRole_id = schedUserRole_id;
		TypeCost = typeCost;
		ID = iD;
		aRequire = Require;
		this.User_id = User_id;
	}
	@Override
	public void run() throws ClientProtocolException, JSONException, IOException {
		UpdateAndroidScheduleRequest request = new UpdateAndroidScheduleRequest();
		request.setCode(Code);
		request.setName(Name);
		request.setPrice(Price);
		request.setExecute_date(Execute_date);
		request.setAuthKey(AuthKey);
		request.setHospital_id(Hospital_id);
		request.setAddress(Address);
		request.setLevel(Level);
		request.setCase_id(Case_id);
		request.setAddInfos(AddInfos);
		request.setSchedUserRole_id(SchedUserRole_id);
		request.setTypeCost(TypeCost);
		request.setPrice(Price);
		request.setRequire(aRequire);
		request.setID(ID);
		request.setUser_id(User_id);
		UpdateAndroidScheduleResponse reponse = protocol.updateAndroidSchedule(request);
		for (BMSListener mlistener : listener){
			mlistener.finishUpdateAndroidSchedule(reponse.getReturnCode(), reponse.getResultMsg());
		}
	}
	
	@Override
	public void timeoutCallback() {
		for (BMSListener mlistener : listener){
			mlistener.finishUpdateAndroidSchedule(protocol.STATUS_CODE_GENERIC_FAIL_CONECTTION, "");
		}
	}
	
	
	
	
}
